'use strict';

import React from 'react';
import { connect } from 'react-redux';
import { Link } from 'react-router';
import * as actions from '../../actions/zhekou_limit_step1';
import { Button,Step,Breadcrumb,Input } from 'qnui';
import { Row, Col } from 'qnui/lib/grid';
import GoodsItemsZhekou from 'components/goods-items-zhekou/index';
import SystemDialog from 'components/system-dialog/index';
import './index.scss';
class ZhekouLimitStep2 extends React.Component {

  constructor(props) {
    super(props);
	 this.dispatch = this.props.dispatch;
    this.state = {
			overlayVisible:false,
            value: null,
			search:"",
			hasTag:false,
			isSelectTag:false,
			refreshDialog:false,
        };
  }
	onCloseSystemDialog(){
		this.setState({"refreshDialog":false,"orderDialog":false});
		this.props.dispatch(actions.closeDialog());
	}
	addItemToActive(setItem){
		this.props.dispatch(actions.addLimitItemToActive(setItem,this.props.location.state.activityId));
	}
	addItemsToActive(items){
		for(let i in items){
			this.props.dispatch(actions.addLimitItemToActive(items[i],this.props.location.state.activityId));
		}
	}
  render() {
    return (
      <div className="page2-page">
	      <SystemDialog 
				 loginError={this.props.zhekou_limit_step1.loginError}
			    creating={this.props.zhekou_limit_step1.creating}
			    message={this.props.zhekou_limit_step1.message}
			    error={this.props.zhekou_limit_step1.error}
				 refreshDialog={this.state.refreshDialog}
				 orderDialog={this.state.orderDialog}
				 onCloseDialog={this.onCloseSystemDialog.bind(this)}
				/>
            
	      <Row style={{background:"#F6F6F6",margin:"3px 0"}} justify="start">
					<Col span="8" align="center">
						  <Breadcrumb maxNode={5}>
							  <Breadcrumb.Item>打折活动</Breadcrumb.Item>
							  <Breadcrumb.Item>创建</Breadcrumb.Item>
							  <Breadcrumb.Item>限购折扣</Breadcrumb.Item>
						  </Breadcrumb>
					</Col>
					<Col offset="2">
							<Step current={1} type="dot">
								<Step.Item title="设置活动" />
								<Step.Item title="选择商品" />
								<Step.Item title="完成"/>
							</Step>
					</Col>
			 </Row>
			 <GoodsItemsZhekou 
			 		activeType="limit" 
			 		showDepot={true} 
			 		maxSelect={150}
			 		addItemToActive={this.addItemToActive.bind(this)}
			 		addItemsToActive={this.addItemsToActive.bind(this)}
			 		setDoneItems={this.props.zhekou_limit_step1.setItems}
			 		/>
	    </div>
    );
  }
}

export default connect((state)=> {
  return {
    zhekou_limit_step1: state.zhekou_limit_step1
  };
})(ZhekouLimitStep2);
